#include "StdAfx.h"
#include "MyGtalkMessCon.h"




int MyGtalkMessCon::SetUnameAndPass(std::string &uname, std::string &pass)
{
		suname=uname;
		spass=pass;
		return 0;
}
MyGtalkMessCon * m_MyGtalkCon;
UINT ThreadHandleMessage(LPVOID pParam)
{
	
	m_MyGtalkCon->start();
	return 0;
}
int MyGtalkMessCon::FormatDisplayMessage(CString cs_msg)
{
	CWnd   *pParentWnd   =     (CWnd   *)AfxGetApp()->m_pMainWnd;
		
	//CStatic   *pStatic   =   (CStatic  *)pParentWnd-> GetDlgItem(IDC_LIST_MESS);//IDC_STATIC_Mess) ;
	CListBox * pListBox = (CListBox *)pParentWnd-> GetDlgItem(IDC_LIST_MESS);
	pListBox->ResetContent();
	CString csLeft,csRight;
	csRight = cs_msg;
	int imessbeg,imessend;
	char split = '*';
	//first line
	//iPos = csRight.Find(split);
	//if(iPos == -1)
	//	return 0;
	//second line ,trim a *
	//csRight = csRight.Mid(iPos+1,csRight.GetLength());
	//csLeft = csRight.Mid(0,iPos);

	while(  ( imessbeg = csRight.Find(split) ) != -1 )
	{	
		csRight.SetAt(imessbeg,' ');
		while( (imessend =  csRight.Find(split) ) != -1 )
		{
			if(csRight[imessend+2] == ')' || csRight[imessend+3] == ')')
			{
				
				csLeft = csRight.Mid(imessbeg+1,imessend-imessbeg-1);
				csRight = csRight.Mid(imessend,csRight.GetLength());	
				//if(csRight[imessbeg+2] == ')' || csRight[imessbeg+3] == ')')
				//{
				//	csRight.SetAt(iPos,' ');
				//}
					
				pListBox->AddString(csLeft);
				break;
			}
			else
			{
				csRight.SetAt(imessend,' ');
			}
		}
		
	}
	pListBox->AddString(csRight);
	//pListBox->AddString(cs_msg);
	//cs_msg.Replace(L"*",L"\r\n");
	return 1;
}
